package org.example.dto;

import lombok.Data;

/**
 * 统一返回封装类
 *
 * @author heihaier@mmears.com
 * Date: 2018/8/21
 * Time: 下午8:36
 */
@Data
public class Resp<T> {
    private String code;
    private String msg;
    private T data;

    public Resp() {

    }

    public Resp(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Resp(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Resp(T data) {
        this.data = data;
        this.code = "0";
    }

    public static <T> Resp<T> ok(T data) {
        return new Resp<>(data);
    }
    public static <T> Resp<T> success(T data) {
        return new Resp<>(data);
    }

}
